PartNcKFailDist <- function(N,K,PartTree,PartProbs) {
  
  # This function is designed to calculate the total cost from each NcK combination of
  # potentially failed parts.
  #
  # Inputs
  #   N - scalar, total number of parts
  #   K - scalar, indicates the number of critical components, after which probability of
  #       failure becomes nearly zero.
  #
  #   PartTree - Nx1 vector indicating the hierarchy of the parts. Comes from the list of 
  #              sub-components that are worth replacing if they fail, otherwise the
  #              entire assembly should simply be replaced instead.
  #
  #   PartProbs - Nx1 vector indicating each part's probability of failure.
  #
  # Outputs
  #   PartFailDist - Nx1 vector of each part's probability of failure.
  #
  # Written by: Sean Gonzalez - WILLCOR, Inc. - September, 2012
  #_____________________________________________________________
 
  # Go through each k of K and determine the probability from each
  P_exactly_k[1] <- ProbNcKwAsymPartProbs(N,1,PartTree,PartProbs);
  for (k in 2:K) {
    P_exactly_k[k] <- ProbNcKwAsymPartProbs(N,k,PartTree,PartProbs);
    
    # Each kmo_p needs to be added to the previous one.  Old Code:
    # probThusFar(k) = probEach(k) + probThusFar(k-1)*(1 -probEach(k));
    P_min_k[k] = P_exactly_k[k] + P_min_k[k-1]*(1-P_exactly_k[k])
  }
  return(P_exactly_k,P_min_k)
}